package com.sky.controller.user;

import com.sky.annotation.RateLimit;
import com.sky.service.impl.RankingServiceImpl;
import com.sky.service.impl.RecommendServiceImpl;
import com.sky.vo.RankingResponse;
import com.sky.vo.RecommendResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@Api(tags = "图书推荐接口")
@RequestMapping("/user/recommend")
public class RecommendController {
    @Autowired
    private RecommendServiceImpl recommendService;

    /**
     * 获取图书推荐数据
     * @param type
     * @return
     */
    @GetMapping()
    @ApiOperation("获取图书推荐数据")
    @RateLimit(limit = 10, timeout = 1)  // 每秒最多 10 次请求
    public RecommendResponse getRecommendList(String type){
        RecommendResponse response = recommendService.getRecommendList(type);
        return response;
    }

}
